﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>社区好生活</title>
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta content="yes" name="apple-touch-fullscreen">
    <meta name="format-detection" content="telephone=no">
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" />
    <link href="../css/ydui.css?v=1.1.4" rel="stylesheet" />
    <script src="../js/ydui.flexible.js"></script>
    <link rel="stylesheet" type="text/css" href="../css/all.css?v=20180302"/>
    <link href="https://cdn.bootcss.com/Swiper/3.4.2/css/swiper.min.css" rel="stylesheet">
</head>
<body ms-controller="mall">
    <div class="g-flexview">
        <header class="m-navbar">
            <a onclick="history.go(-1)" class="navbar-item">
                <i class="iconfont icon-back"></i>
            </a>
            <div class="navbar-center">
                <span class="navbar-title">商城</span>
            </div>
            <a class="right-tabiconf iconfont icon-leimupinleifenleileibie"></a>
        </header>
        <div class="g-scrollview">
            <div class="firststyle">
                <div class="mall-classify">
                    <a href="" class="tab-item change">综合</a>
                    <a href="" class="tab-item">销量</a>
                    <a href="" class="tab-item">价格<div class="topup"><p class="iconfont icon-shang1"></p><p class="iconfont icon-iconfuben09"></p></div></a>
                    <a href="" class="tab-item">信用</a>
                </div>
                <div class="mall-list" id="allquestion">
                    <div class="mall-listcontent clearfix " ms-for="el in @data">
                        <a class="J_Link">
                            <a ms-attr="{'href':'detail.html?detailID='+el.ID}"><img ms-attr="{'src':ComFunJS.FilePath(el.ImgUrl,'/300/220')}" class="fl"></a>
                            <aside>
                                <p>{{el.Title}}</p>
                                <h1>{{el.Desp}}</h1>
                                <p class="price">¥{{el.Price2}}<span>¥{{el.Price1}}</span></p>
                                <p class="odds" ms-if="el.Desp!=''">限时促销</p>
                                <a class="mallbtn iconfont icon-gouwuche1" ms-on-click="@clickbtn"></a>
                            </aside>
                        </a>
                    </div>
                </div>
            </div>
            <div class="iconfont trolley icon-03f" id="btn1-add">
                <i ms-if="@gouwunumebr>0">{{@gouwunumebr}}</i>
            </div>
        </div>
    </div>

    <script src="https://cdn.bootcss.com/jquery/3.2.0/jquery.min.js"></script>
    <script src="../js/ydui.js"></script>
    <script src="../js/gouwu.js"></script>
    <script src="../js/ComFunJS.js?v=20180331"></script>
    <script src="../js/avalon.mobile.min.js"></script>
    <script>
        var model = avalon.define({
            $id: 'mall',
            data: [],
            page: "",
            gouwunumebr: 0,
            number: ComFunJS.getQueryString('number'),
            second: ComFunJS.getQueryString('second'),
            getdata: function (callback) {
                $.getJSON('/api/pro/list/' + model.number + '/' + model.second + '?pageindex=' + model.page + '&' + 'pagesize=10', function (r) {
                    typeof callback == 'function' && callback(r.result);
                })
            },
            clickbtn: function (event) {
                model.gouwunumebr++
            }
        })
        avalon.ready(function () {

            init();

        })
        function init() {

            model.data = [];
            model.page = 1;
            $('#allquestion').infiniteScroll({
                binder: '.g-scrollview',
                pageSize: 10,
                initLoad: true,
                backposition: true,
                jumpLink: '.J_Link',
                loadingHtml: '<img src="http://static.ydcss.com/uploads/ydui/loading/loading10.svg"/>',
                loadListFn: function () {
                    var def = $.Deferred();
                    model.getdata(function (listArr) {

                        listArr.forEach(function (val) {
                            setTimeout(function () {
                                model.data.push(val);
                                clickb()
                            }, 100)
                        });
                        def.resolve(listArr, model.page);
                        model.page++;

                    });
                    return def.promise();
                },
                loadStorageListFn: function (ret, retPage) {
                    var def = $.Deferred();
                    model.page = retPage;
                    ret.forEach(function (listArr) {
                        listArr.list.forEach(function (val) {
                            model.data.push(val);
                        });
                    });
                    avalon.scan(document.body);
                    def.resolve();
                    return def.promise();
                }
            });
        }

    </script>
</body>
</html>
